package Odhgos_Polhs;


import java.util.ArrayList;

public class URS {
    
    //Attributes
    private ArrayList<Reservation> submittedReservationsList = new ArrayList<Reservation>();
    private ArrayList<Reservation> waitingListReservationsList = new ArrayList<Reservation>();
    private ArrayList<Reservation> confirmedReservationsList = new ArrayList<Reservation>();
    
    //Constructor
    public URS() {
    }
    
    //All Setters & Getters
    public ArrayList<Reservation> getConfirmedReservationsList() {
        return confirmedReservationsList;
    }

    public ArrayList<Reservation> getSubmittedReservationsList() {
        return submittedReservationsList;
    }

    public ArrayList<Reservation> getWaitingListReservationsList() {
        return waitingListReservationsList;
    }

    public void setConfirmedReservationsList(ArrayList<Reservation> confirmedReservationsList) {
        this.confirmedReservationsList = confirmedReservationsList;
    }

    public void setSubmittedReservationsList(ArrayList<Reservation> submittedReservationsList) {
        this.submittedReservationsList = submittedReservationsList;
    }

    public void setWaitingListReservationsList(ArrayList<Reservation> waitingListReservationsList) {
        this.waitingListReservationsList = waitingListReservationsList;
    }
    
    
    //Other methods
    public void addReservationToSubmittedList(Reservation reserve){
        submittedReservationsList.add(reserve);      
    };
    
    public void addReservationToWaitingList(Reservation reserve){
        waitingListReservationsList.add(reserve);
    };

    public void addReservationToConfirmedList(Reservation reserve){
        confirmedReservationsList.add(reserve);
    };

    public void removeReservationFromSubmittedList(Reservation reserve){
        int idx = 0;
        for (Reservation element:submittedReservationsList){
            if (element == reserve){
                idx = submittedReservationsList.indexOf(element);
            }
        }
        submittedReservationsList.remove(idx);
    };

    public void removeReservationFromWaitingList(Reservation reserve){
        int idx = 0;
        for (Reservation element:waitingListReservationsList){
            if (element == reserve){
                idx = waitingListReservationsList.indexOf(element);
            }
        }
        waitingListReservationsList.remove(idx);
    };

    public void removeReservationFromConfirmedList(Reservation reserve){
        int idx = 0;
        for (Reservation element:confirmedReservationsList){
            if (element == reserve){
                idx = confirmedReservationsList.indexOf(element);
            }
        }
        confirmedReservationsList.remove(idx);
    };

    public void upgradeToWaitngList(Reservation reserve){
        waitingListReservationsList.add(reserve);
        removeReservationFromSubmittedList(reserve);
    };

    public void upgradeToConfirmedList(Reservation reserve){
        confirmedReservationsList.add(reserve);
        removeReservationFromWaitingList(reserve);
    };

    
}
